<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<jsp:include page="/WEB-INF/jsp/common/common.jsp" />
<jsp:include page="/WEB-INF/jsp_lib/validate.jsp" />
<link rel="stylesheet"
	href="${path}/style_lib/zTree_v3/css/zTreeStyle/zTreeStyle.css"
	type="text/css"></link>
<script type="text/javascript"
	src="${path}/style_lib/zTree_v3/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript"
	src="${path}/style_lib/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript">
	var city_name;
	function zTreeOnClick(event, treeId, treeNode, clickFlag) {
		getName(treeNode.code);
		window.parent
				.save(treeNode.id, treeNode.name, treeNode.code, city_name);
	};
	function getName(id) {
		var super_id;
		super_id = id.substring(0, 2) + "0000";
		$.each(zNodes, function(i, n) {
			if (zNodes[i].code == super_id)
				city_name = zNodes[i].name;
		});
	}
	var setting = {
		edit : {
			enable : false
		},
		view : {
			fontCss : {
				"margin" : "2px"
			}
		},
		data : {
			simpleData : {
				enable : true,
				name : 'name',
				code : 'code',
				idKey : '_id',
				pIdKey : 'super_id',
				rootPId : 'root'
			}
		},
		callback : {
			onClick : zTreeOnClick
		}
	};
	var zNodes = $.parseJSON('${bankJson}');
	var zTreeObj;
	$(function() {
		$.each(zNodes, function(i, n) {
			zNodes[i].iconOpen = "${path}/style_lib/zTree_v3/icon/open.jpg";
			zNodes[i].iconClose = "${path}/style_lib/zTree_v3/icon/close.jpg";
			zNodes[i].icon = "${path}/style_lib/zTree_v3/icon/open.jpg";

			zNodes[i].id = zNodes[i]._id;

		});

		zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
		zTreeObj.expandAll(false);
	});
</script>
</head>
<body style="width:95%">
	<!-- 一次性加载树 -->
	<div class="row-fluid">
		<div
			style="float: left;width:300px;overflow:auto;border:solid 1px #B1E6EC; width:95%">
			<div class="w-box">
				<h2 style="border-bottom:solid 1px #B1E6EC;">
					<div>
						<a title="添加根节点" href="#"
							style="font-size:16px;color:#3B78BE;margin-right: 10px;">机构列表</a>
					</div>
				</h2>
				<div class="zTreeDemoBackground left" style="margin-right: 10px;">
					<ul id="treeDemo" class="ztree"></ul>
				</div>
			</div>
		</div>
	</div>
	</div>
</body>
</html>
